package come.banking.oop;

import java.util.Scanner;

public class Account {
    private String id;
    private int password;
    private String name;
    private String personId;
    private String email;
    private double balance;
    Scanner in = new Scanner(System.in);

    public Account() {
    }

    public Account(String id, int password, String name, String personId, String email, double balance) {
        setBalance(balance);
        setEmail(email);
        setId(id);
        setName(name);
        setPassword(password);
        setPersonId(personId);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getPassword() {
        return password;
    }

    public void setPassword(int password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public Scanner getIn() {
        return in;
    }

    public void setIn(Scanner in) {
        this.in = in;
    }

    private void export() {

        int i = 0;
        System.out.println("请输入账户：");
        String passid = in.next();
        System.out.println("请输入密码：");
        int word = in.nextInt();
        if ((passid.equals(id)) && (word != password)) {
            System.out.println("您输入账户密码不正确请重新输入");
            System.out.println("请输入账户：");
            passid = in.next();
            System.out.println("请输入密码：");
            word = in.nextInt();
            while (i > 3) {
                System.out.println("输入次数过多，请下次再来");
                return;
            }
        }
    }

    public void deposit() {
        export();
        System.out.println("请输入您的存款金额");
        double amountDeposit = in.nextDouble();
        this.balance += amountDeposit;
        System.out.println("您好" + name + "欢迎存入" + amountDeposit + "元，您的余额为" + this.balance);
        System.out.println("欢迎下次再来");
    }

    public void withDraw() {
        export();
        double amountDeposit;
        System.out.println("请输入您的取款金额");
        amountDeposit = in.nextDouble();
        if (this.balance < 0 &&amountDeposit>this.balance) {
            System.out.println("抱歉余额不足");
            return;
        }
        this.balance -= amountDeposit;

        System.out.println("您好" + name + "欢迎取出" + amountDeposit + "元，您的余额为" + this.balance);
        System.out.println("欢迎下次再来");


    }

    public void test() {
        System.out.println("你好" + name + "先生,欢迎来到中国银行。\n您输入的email为" + email + "\n您的身份证号为" + personId + "\n您目前账户为" + id + "\n您目前账户密码为" + password + "\n您目前账户余额为" + balance);


    }


}
